﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using SISLOG.BusinessEntities;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.Unity;
using System.Data.Common;

namespace SISLOG.DataAccess
{
    public class AreaDAO:MasterDAEL,IAreaDAO
    {

        public List<Area> GetAllFromArea()
        {
            var areas = dbSisLog.ExecuteSprocAccessor<Area>("GetAllFromArea");
            return areas.ToList();
        }


        public void RegistrarArea(Area area)
        {
            DbCommand comando = dbSisLog.GetStoredProcCommand("RegistrarArea");
                        dbSisLog.AddInParameter(comando,"IdArea",System.Data.DbType.Int32, area.IdArea);
                        dbSisLog.AddInParameter(comando, "NombreArea", System.Data.DbType.String,area.NombreArea);

                        dbSisLog.ExecuteNonQuery(comando);
        }


        public Area GetAllFromAreaByIdArea(int idArea)
        {
            var areas = dbSisLog.ExecuteSprocAccessor<Area>("GetAllFromAreaByIdArea", idArea);
            return areas.SingleOrDefault();
        }
    }
}